package org.rbreznak.tronco.client;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Screen2 extends Screen{
	private static final long serialVersionUID = 1L;

	private JLabel directionsText = new JLabel();
	private JButton btnExit = new JButton(new ImageIcon("img/buttons/exit.png"));
	private JButton btnCard = new JButton(new ImageIcon("img/buttons/swipecard.png"));
	private JButton btnUNIX = new JButton(new ImageIcon("img/buttons/unixaccount.png"));
	private JButton btnNewUser = new JButton(new ImageIcon("img/buttons/newuser.png"));
	
	public Screen2() {
		JPanel panel = new JPanel();
		panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
		panel.setBackground(new Color(0,0,0));
		
		setLayout(new BorderLayout());
		setBackground(new Color(0,0,0));
		
		FormatUI.formatLabel(directionsText);
		
		btnExit.setAlignmentX(Component.RIGHT_ALIGNMENT);
		
		FormatUI.formatImageButton(btnExit);
		
		add(btnExit, BorderLayout.SOUTH);
		add(directionsText, BorderLayout.NORTH);
		add(panel, BorderLayout.CENTER);
		
		directionsText.setText("Please Select a Login Method");
		
		btnCard.setAlignmentX(Component.CENTER_ALIGNMENT);
		btnUNIX.setAlignmentX(Component.CENTER_ALIGNMENT);
		btnNewUser.setAlignmentX(Component.CENTER_ALIGNMENT);
		
		FormatUI.formatImageButton(btnCard);
		FormatUI.formatImageButton(btnUNIX);
		FormatUI.formatImageButton(btnNewUser);
		
		btnCard.addActionListener(this);
		
		panel.add(btnCard);
		panel.add(btnUNIX);
		panel.add(btnNewUser);
		
		this.setVisible(true);
	}
	
	public void actionPerformed(ActionEvent arg0) {
		_fireScreenUpdate();
	}

	@Override
	public void decideNext() {
		if(nodes.size() > 0) {
			setNext(nodes.get(0));
		}
	}
	
	@Override
	public String toString() {
		return directionsText.getText();
	}

	@Override
	public void reset() {
		setNext(null);
	}
}
